/*
 * KP ebdesk
 */
package com.ebdesk.model.masterdata;

import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Zulfikar
 */
public class TablePrinterModel extends AbstractTableModel{
    private Object[][] rowData;  
    private String[] columnNames;  

    public TablePrinterModel(Object[][] rowData, String[] columnNames) {  
        this.rowData = rowData;  
        this.columnNames = columnNames;  
    }  
    @Override
    public int getColumnCount() {
        return columnNames.length;
    }

    @Override
    public String getColumnName(int column) {
        return columnNames[column];
    }

    @Override
    public int getRowCount() {
        return rowData.length;
    }

    @Override
    public Object getValueAt(int row, int column) {
        return rowData[row][column];
    }

    @Override
    public Class getColumnClass(int column) {
        Object value=this.getValueAt(0,column);  
        return (value==null?Object.class:value.getClass()); 
    }

    @Override
    public void setValueAt(Object value, int row, int column) {
        rowData[row][column] = value;
        fireTableCellUpdated(row, column);        
    }
    
}
